// components/UpRecodeList/UpRecodeList.js
import { request } from '../../utils/util'
Component({
  /**
   * 组件的属性列表
   */
  properties: {
      type:{
        type:String,
      },
      name:{
        type:String,
      },
      time:{
        type:String,
      },
      size:{
        type:String
      },
      uploadMan:{ 
        type:String,
      },
      preview:{
        type:Number
      },
      download:{
        type:Number
      },
      fileItem:{
        type:Object
      }
  },

  /**
   * 组件的初始数据
   */
  data: {

  },

  /**
   * 组件的方法列表
   */
  methods: {
      /**
       * 预览
       */
        preview(){
          
          const noPreview = wx.getStorageSync('no_preview')
          let isNoPreview = false
          noPreview.forEach( item =>{
            if(this.properties.fileItem.types === item.name){
              isNoPreview = true
              wx.showToast({
                title: '该类型不支持预览',
                icon:'none'
              })
              return
            }
          }) 
          if(!isNoPreview){
            const param = {
              file_hash:this.properties.fileItem.uuid
            }
            request("POST","/api/upload/doc/preview/",param,"",true)
          .then(res =>{
            if(res.statusCode === 200){
              wx.navigateTo({
                url: `/pages/webView/preview/preview?url=${
                  encodeURIComponent(res.data.url)}`,
              })
            }
          })
          }
        }
  }
})
